package Java多线程技术.第3章.多生产一消费;

/*
* 解决wait条件改变与假死
* 1、条件发生改变时没有得到及时响应，所以多个呈wait状态的线程被唤醒，
* 继而去执行remove(0)代码出现异常，解决办法是将if语句改为while语句
*
* 2、假死情况 解决办法是将notify方法改成notifyAll方法
*
*/

public class Run3 {
    public static void main(String[] args) {
        MyStack3 myStack = new MyStack3();

        P3 p2 = new P3(myStack);
        P3 p3 = new P3(myStack);
        P3 p4 = new P3(myStack);
        P3 p5 = new P3(myStack);
        C3 c21 = new C3(myStack);

        PThread3 pThread2 = new PThread3(p2);
        PThread3 pThread3 = new PThread3(p3);
        PThread3 pThread4 = new PThread3(p4);
        PThread3 pThread5 = new PThread3(p5);

        CThread3 cThread21 = new CThread3(c21);


        pThread2.start();
        pThread3.start();
        pThread4.start();
        pThread5.start();

        cThread21.start();

    }
}
